home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / CHIP Haziran 2001.iso / prog / haziran / 19 / setup.exe / data.z / ask_data.frm < prev    next >
Text File  |  2001-04-11  |  3KB  |  99 lines

  1. VERSION 5.00
  2. Begin VB.Form ask_data 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Insert Data"
  5.    ClientHeight    =   1296
  6.    ClientLeft      =   36
  7.    ClientTop       =   264
  8.    ClientWidth     =   1824
  9.    Icon            =   "ask_data.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   1296
  14.    ScaleWidth      =   1824
  15.    StartUpPosition =   3  'Windows Default
  16.    Begin VB.CommandButton Write_Button 
  17.       Caption         =   "Write"
  18.       Default         =   -1  'True
  19.       Height          =   252
  20.       Left            =   480
  21.       TabIndex        =   1
  22.       Top             =   840
  23.       Width           =   852
  24.    End
  25.    Begin VB.TextBox DataText 
  26.       Alignment       =   2  'Center
  27.       Height          =   288
  28.       Left            =   480
  29.       MaxLength       =   2
  30.       TabIndex        =   0
  31.       Text            =   "00"
  32.       Top             =   240
  33.       Width           =   852
  34.    End
  35. End
  36. Attribute VB_Name = "ask_data"
  37. Attribute VB_GlobalNameSpace = False
  38. Attribute VB_Creatable = False
  39. Attribute VB_PredeclaredId = True
  40. Attribute VB_Exposed = False
  41. '
  42. ' File - ask_data.frm
  43. '
  44. ' This application reads and writes data to the Parallel Port, and is
  45. ' controlled via a graphical user interface - pp_gui.frm
  46. ' The Parallel Port is accessed directly on the motherboard, using
  47. ' WinDriver functions.
  48. '
  49.  
  50. Private Sub Form_Load()
  51.     ask_data.DataText = Hex(g_Data)
  52.     ask_data.DataText.Refresh
  53.     ask_data.DataText.SelStart = 0
  54.     ask_data.DataText.SelLength = 2
  55. End Sub
  56.  
  57. Private Sub Write_Button_Click()
  58.     If (ask_data.DataText = "") Then
  59.         MsgBox "Data is empty.", vbExclamation + vbOKOnly, "Error"
  60.         GoTo error
  61.     End If
  62.     
  63.     If (Not IsHexText(ask_data.DataText)) Then
  64.         MsgBox "The value you entered is not a valid Hexadesimal value." & Chr$(13) & _
  65.             "Enter a new value.", vbExclamation + vbOKOnly, "Error"
  66.         GoTo error
  67.     End If
  68.     
  69.     g_Data = Val("&H" & ask_data.DataText)
  70.     Unload ask_data
  71.     GoTo finish
  72.     
  73. error:
  74.     ask_data.DataText = Hex(g_Data)
  75.     ask_data.DataText.Refresh
  76.     ask_data.DataText.SetFocus
  77.     ask_data.DataText.SelStart = 0
  78.     ask_data.DataText.SelLength = 2
  79.  
  80. finish:
  81. End Sub
  82.  
  83. Private Function IsHexText(str As String) As Boolean
  84.     Dim str0, str1 As String
  85.     
  86.     str0 = Left(str, 1)
  87.     str1 = Right(str, 1)
  88.     
  89.     If ((Val("&H" & str0) = 0) And (Asc(str0) <> 48)) _
  90.         Or _
  91.         ((Val("&H" & str1) = 0) And (Asc(str1) <> 48)) Then
  92.         IsHexText = False
  93.     Else
  94.         IsHexText = True
  95.     End If
  96. End Function
  97.  
  98.  
  99.